<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>出价防扰设置</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/page.css">
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/media.js"></script>
    <script src="../js/common.js"></script>
    <style>

    </style>
</head>

<body>
    <!--头部-->
    <div class="public-header flex">
        <!--<span class="public-header-left-search"></span>-->
        <span class="public-header-left-back"></span>
        <span class="public-header-center">出价防扰设置</span>
        <span class="public-header-right">保存</span>
    </div>

    <!--正文-->
    <div class="Bidding-settings bc-gray">
        <section class="section1">
            <ul>
                <li class="flex">
                    <span>首次出价需要认证手机号</span>
                    <div class="checkbox checkbox-slider--b-flat">
                        <label>
				<input type="checkbox" class="" id="op"><span></span>
			</label>
                    </div>
                </li>

            </ul>
        </section>

        <section class="section2">
            <ul>
                <li class="flex">
                    <span>违约率小于30%<font style="font-size:.08rem;">(2笔以上)</font></span>
                    <div class="checkbox checkbox-slider--b-flat">
                        <label>
				<input type="checkbox" class="" id="op1"><span></span>
			</label>
                    </div>
                </li>
                <li class="flex" >
                    <span>买家支付系统保证金</span>
                    <em class="" data-se='1'>勾</em>
                </li>
                <li class="flex" >
                    <span>买家禁止出价</span>
                    <em class="" data-se='2'>勾</em>
                </li>

            </ul>
        </section>

        <section class="section3">
            <ul>
                <li class="flex">
                    <span>退货比率小于30% <font style="font-size:.08rem;">(2笔以上)</font></span>
                    <div class="checkbox checkbox-slider--b-flat">
                        <label>
				<input type="checkbox" class="" id="op2"><span></span>
			</label>
                    </div>
                </li>
                <li class="flex">
                    <span>买家支付系统保证金</span>
                    <em  data-se='1'>勾</em>
                </li>
                <li class="flex">
                    <span>买家禁止出价</span>
                    <em  data-se='2'>勾</em>
                </li>

            </ul>
        </section>

    </div>




    <script>
        $(function () {
            $('#op').click(function () {
                $(this).toggleClass('checked')

            })
            $('#op1').click(function () {
                $(this).toggleClass('checked')
                if ($(this).hasClass('checked') == false) {
                    $(this).closest('ul').find('em').removeClass('active')
                }
            })
            $('#op2').click(function () {
                $(this).toggleClass('checked')
                if ($(this).hasClass('checked') == false) {
                    $(this).closest('ul').find('em').removeClass('active')
                }
            })
            $('.section2 li:gt(0)').click(function () {
                if ($('#op1').hasClass('checked')) {
                    $(this).find('em').toggleClass('active').closest('li').siblings().find('em').removeClass(
                        'active');
                }
            })
            $('.section3 li:gt(0)').click(function () {
                if ($('#op2').hasClass('checked')) {
                    $(this).find('em').toggleClass('active').closest('li').siblings().find('em').removeClass(
                        'active');
                }
            })
            $('.public-header-right').click(function () {
                var is_first, is_first_Msg, default_rate, ok1, ok2;
    
                if ($('#op').hasClass('checked')) {
                    is_first = 1
                } else {
                    is_first = 0
                }

        
                if ($('#op1').hasClass('checked')) {
                    if ($('.section2 li:gt(0) em').hasClass('active') == false) {
                        alert('请选择一个违约率的选项')
                    }
                    is_first_Msg = $('.section2 .active').data('se');
                    ok1 = 1;
                }else{
                    is_first_Msg = 0;
                    ok1 = 1;
                }
                if ($('#op2').hasClass('checked')) {
                    if ($('.section3 li:gt(0) em').hasClass('active') == false) {
                        alert('请选择一个退货率的选项')
                    }
                    default_rate = $('.section3 .active').data('se');
                    ok2 = 1;
                }else{
                    default_rate = 0
                    ok2 = 1;
                }
                if (ok1 == 1 && ok2 == 1) {

                    console.log(is_first,is_first_Msg,default_rate)
                    $.ajax({
                        url: base_url + 'ZITAOHUI/store/antiDisturbance',
                        data: {
                            store_id: s_id,
        
                            is_first: is_first,
                           
                            is_first_Msg: is_first_Msg,
               
                            default_rate: default_rate,
                        },
                        success:function(data){
                            console.log(data)
                      
                            if(data.estend.list == "设置成功"){
                                window.location.href = '../page/setting-center.html'
                            }
                        }
                    })
                }

            })

        })
    </script>
</body>

</html>